package com.example.shorg.dataobject;

import com.example.shorg.enums.OrderStatusEnum;
import com.example.shorg.enums.PayStatusEnum;
import com.example.shorg.utils.serializer.Date2LongSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Data
//@DynamicUpdate  //自动更新
public class OrderMaster {

    /**订单id**/
    @Id
    private String orderId;

    /**订单名称*/
    private String buyerName;

    /**订单手机号码*/
    private String buyerPhone;

    /**订单地址*/
    private String buyerAddress;

    /**微信的openid*/
    private String buyerOpenid;

    /**订单价格*/
    private BigDecimal orderAmount;

    /**订单状态 0新的订单，1已完成， 2已取消*/
    private Integer orderStatus = OrderStatusEnum.NEW.getCode();

    /**订单的支付状态  0等待完成*/
    private Integer payStatus = PayStatusEnum.WAIT.getCode();

    /**订单的创建时间*/
    @JsonSerialize(using = Date2LongSerializer.class)
    @CreationTimestamp
    private Date createTime;

    /**更新时间*/
    @JsonSerialize(using = Date2LongSerializer.class)
    @UpdateTimestamp
    private Date updateTime;
}
